home *** CD-ROM | disk | FTP | other *** search
- /*______________________________________________________________________
- | _|_ |
- | ¿ Craig's Lib:Twiddle.c Started: 08/21/92 |
- | Last Modified: 10/13/92 |
- | |
- | Copyright © 1991 by Craig A. Marciniak All rights reserved. |
- _______________________________________________________________________*/
-
- #include "twiddle.h"
-
- /*______________________________________________________________________*/
- /* This is a killer little function to get a range of bits from a byte */
- /* You simply pass the value as x, were to start as p,and how many bits */
- /* to the left you want. C.A.M. 12/3/92 */
- /*______________________________________________________________________*/
-
- unsigned getbits(unsigned x,int p,int n)
- {
- return (x>>(p+1-n)) & ~(~0 <<n);
- }
-
- /*___________________ long byte swap for Intell <-> Motorola Conversions*/
-
- unsigned long longswap(unsigned long ul)
- {
- return (ul >> 24) | ((ul >> 8) & 0xff00) | ((ul << 8) & 0xff0000) | (ul << 24);
- }
-
- /*___________________ word byte swap for Intell <-> Motorola Conversions*/
-
- unsigned short shrtswap(unsigned int us)
- {
- return ((us >> 8) | (us << 8)) & 0xffff;
- }
-
- /*_________________________________________________ Pascal String Copy _*/
-
- void PStrCpy(register StringPtr p1, register StringPtr p2)
- {
- if (p1 && p2)
- BlockMove(p1, p2, (long) (*p1 + 1));
- }
-
- /*_______________________________________________________________________*/